package com.zhongbo.java.websocket.web.controler;

import com.zhongbo.java.websocket.vo.RestResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 说明：
 *
 * @author 钟波dellNotebook
 * @since 2025年03月24日 星期一 14:03:01
 */
@RestController
@RequestMapping("redisTest")
@Api(tags = "redis测试接口")
public class RedisTestController {

    @Autowired
    private RedisTemplate<String,String> redisTemplate;

    @GetMapping("testSet")
    @ApiOperation("测试设置值")
    public RestResultVo<String> testSet(String key,String value){
        redisTemplate.opsForValue().set(key,value);
        return RestResultVo.ok(null);
    }

    @GetMapping("testGet")
    @ApiOperation("测试读取值")
    public RestResultVo<String> testGet(String key){
        String value = redisTemplate.opsForValue().get(key);
        return RestResultVo.ok(value);
    }
}
